/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * <p>Project: RabbitMQ - MQconfig</p>
 * <p>Powered by yzc On 2023-12-25 10:42:14</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
@Component
public class MQconfig {

    @Bean
    public Queue queue(){
        return new Queue("queue-manual");

    }

    /**
     * 主题交换机
     * @return
     */
    @Bean
    public TopicExchange topicExchange(){
        return  new TopicExchange("topic-ex");
    }

    /**
     * 绑定队列
     * @param queue
     * @param topicExchange
     * @return
     */
    @Bean
    public Binding binding(Queue queue,TopicExchange topicExchange){
        //发送信息时 路由键含有 order的消息都会发送到该队列上
        return BindingBuilder.bind(queue).to(topicExchange).with("*.order.*");
    }
}
